<template>
  <el-dialog draggable overflow :title="'装卸审核'" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
    <sk-upload v-model="form.attachments" :limit="10" draggable tip="" :disabled="true">
    </sk-upload>
    <el-form ref="dialogForm" label-width="70px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="搬运人" prop="company_id">
            <el-input v-model="form.company.name" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="金额" prop="amount">
            <el-input v-model="form.amount" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="编号" prop="code">
            <el-input label="编号" placeholder="自动生成" v-model="form.code" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="单据日期" prop="billdate">
            <el-date-picker v-model="form.billdate" type="date" value-format="YYYY-MM-DD" placeholder="请选择日期" disabled>
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="财务备注" prop="financeremark">
            <el-input v-model="form.financeremark" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <sc-VxeTable ref="xGrid1" :data="form.details" :gridOps="gridOps" :tablecode="'comprehensivel_carry_save_finance'">
    </sc-VxeTable>
    <template #footer>
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" :loading="isSaveing" @click="submit()">审 核</el-button>
    </template>
  </el-dialog>
</template>

<script>
import tool from '@/utils/tool';
export default {
  emits: ["success", "closed"],
  components: {},
  data() {
    return {
      gridOps: {
        height: 300,
      },
      form: {
        attachments: [],
        details: [],
      },
      visible: false,
      isSaveing: false,
    };
  },
  mounted() { },
  methods: {
    //显示
    open() {
      this.visible = true;
      return this;
    },
    submit() {
      this.isSaveing = true;
      this.$API.comprehensive.carry.faudit.post({ id: this.form.id, financeremark: this.form.financeremark }).then((res) => {
        if (res.code == 200) {
          this.$emit("success", this.form, this.mode);
          this.visible = false;
          this.$message.success("操作成功");
        }
      }).finally(() => this.isSaveing = false);
    },
    //表单提交方法

    async getItems(id) {
      var res = await this.$API.comprehensive.carry.details.get({ filter: [{ main_id: id }] });
      if (res.code == 200) {
        this.form.details = res.data;
      } else {
        this.$alert(res.message, "提示", { type: "error" });
      }
    },

    //表单注入数据
    setData(data) {
      Object.assign(this.form, tool.removeNull(data));
      this.getItems(data.id);
    },
  },
};
</script>

<style></style>
